Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
RETURN statement and RETURN-VALUE
First you’ll look at a small, but important, procedure topic. Whenever a procedure, whether internal or external, terminates and returns control to its caller, it returns a value to the caller. You can place a
RETURNstatement at the end of your procedure to make this explicit, and to specify the value to return to the caller:
The
return-valuemust be a character value, either a literal or an expression. The caller (calling procedure) can access thisreturn-valueusing the built-inRETURN-VALUEfunction, such as in this example:
If the called procedure doesn’t return a value, then the value returned is either the empty string (“”) or, if an earlier procedure
RUNstatement in the same call stack returned a value, then that value is returned.The
RETURNstatement is optional in procedures. Because an earlierRETURN-VALUEis passed back up through the call stack if there’s no explicitRETURNstatement to erase it, it is good practice to have the statementRETURN “”at the end of every procedure to clear any old value, unless your application needs to pass aRETURN-VALUEback through multiple levels of a procedure call.In addition, you can return to the calling procedure from multiple places in the called procedure by using multiple
RETURNstatements in different places. You could use this technique, for example, to return onereturn-valuerepresenting success (possibly the empty string) and otherreturn-values from different places in the procedure code to indicate an error of some kind.You can also use
RETURN ERRORfrom a procedure to signal an error. You’ll learn more about this option in Chapter 16, " Updating Your Database and Writing Triggers."
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |